package clone3kinds;

/**
 * @Author: dch
 * @Date: 2020/5/15 13:48
 * @Description:深复制（复制对象和其应用对象）
 * 深拷贝不仅复制对象本身，而且复制对象包含的引用指向的所有对象。
 */
public class Student implements Cloneable{
    private String name;
    private Integer age;
    Resume resume;
    Student(String name, Integer age, Resume resume) {
        this.name = name;
        this.age = age;
        this.resume = resume;
    }
    public Object clone() {
        Student student = null;
        try {
            student = (Student) super.clone();//浅拷贝
        } catch (CloneNotSupportedException e) {
            System.out.println(e.toString());
        }
        //深度拷贝
        student.resume = (Resume)resume.clone();
        return student;
    }
}